package com.hyfd.controller.mp;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hyfd.controller.sys.BaseController;
import com.hyfd.service.mp.DataPkgSer;

@Controller
//@Scope("prototype") //开启非单例模式 用于并发控制
public class DataPkgCtl extends BaseController{
	
	@Autowired
	DataPkgSer dataPkgSer;

	@GetMapping("dataPkgListPage")
	public String dataPkgListPage() {
		return "mp/dataPkgList";
	}
	
	@GetMapping("dataPkg")
	@ResponseBody
	public String dataPkgGet(HttpServletRequest req) {
		return dataPkgSer.dataPkgList(req);
	}
	
	@GetMapping("dataPkgList")
	@ResponseBody
	public String dataListGet(HttpServletRequest req) {
		return dataPkgSer.dataListGet(req);
	}
	/**
	 * 根据运营商ID+类型查询流量包
	 * */
	@GetMapping("dataPkgList/{providerId}/{type}")
	@ResponseBody
	public String dataListGetByProId(@PathVariable("providerId") String providerId,@PathVariable("type") String type) {
		return dataPkgSer.dataListGetByProId(providerId,type);
	}	
	
	@GetMapping("dataPkgAddPage")
	public String dataPkgAddPage() {
		return "mp/dataPkgAdd";
	}

	@PostMapping("dataPkg")
	public String providerPost(HttpServletRequest req) {
		return dataPkgSer.dataPkgAdd(req);
	}
	
    @GetMapping("dataPkgEditPage/{id}")
	public String dataPkgEditPage(@PathVariable("id") String id) {
		return dataPkgSer.dataPkgEditPage(id);
	}
	 
	@PutMapping("dataPkg/{id}")
	@ResponseBody
	public String dataPkgPut(@PathVariable("id") String id, HttpServletRequest req,String[] provinceCodeList) {
		return dataPkgSer.dataPkgEdit(req,id,provinceCodeList);
	}
	
	@DeleteMapping("dataPkg/{id}")
	@ResponseBody
	public String dataPkgDel(@PathVariable("id") String id) {
		return dataPkgSer.dataPkgDel(id) ;
	}
  
}
